<!--
 * @Author: Li Zengkun
 * @Date: 2022-07-25 17:21:21
 * @LastEditors: Li Zengkun
 * @LastEditTime: 2022-08-08 08:30:28
 * @Description: 首页
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../css/reset.css">
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="../node_modules/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/index.css">
    <title>首页</title>
</head>

<body class="">
    <header>
        <a id="sidebar-btn">
            <img src="../img/index/more.png" alt="">
        </a>
        本家
        <a href="#">
            <img src="../img/index/search_img.png" alt="">
        </a>
    </header>

    <!-- 滚动区域 -->
    <div class="index-box">

        <div class="banner">
            <div class="carousel">
                <a href="#">
                    <img src="../img/index/banner1.png" alt="">
                </a>
                <a href="#">
                    <img src="../img/index/banner2.png" alt="">
                </a>
            </div>
            <span class="indicator">
                <ul>
                    <li class="active"></li>
                    <li></li>
                </ul>
            </span>
        </div>
        <nav>
            <ul>
                <li>
                    <a href="#">
                        <img src="../img/index/新品.png" alt="">
                        <span>新品/热销</span>
                    </a>
                </li>
                <li>
                    <a href="#">
                        <img src="../img/index/拼团.png" alt="">
                        <span>超值拼团</span>
                    </a>
                </li>
                <li>
                    <a href="#">
                        <img src="../img/index/新人.png" alt="">
                        <span>新人福利</span>
                    </a>
                </li>
                <li>
                    <a href="#">
                        <img src="../img/index/包袋.png" alt="">
                        <span>时尚动态</span>
                    </a>
                </li>
            </ul>
        </nav>

        <div class="content">
            <!-- 热卖 -->
            <div class="sale content-item">
                <div class="headline">
                    <p>精品热卖</p>
                    <p>SALE</p>
                </div>
                <ul class="goods-list">
                    <li>
                        <a href="#">
                            <img src="../img/index/t (8).png" alt="">
                            <div class="text">
                                <div class="title">英式经典三方女士风衣</div>
                                <div class="price">￥<span>599</span></div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="#">
                            <img src="../img/index/t (8).png" alt="">
                            <div class="text">
                                <div class="title">英式经典三方女士风衣</div>
                                <div class="price">￥<span>599</span></div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="#">
                            <img src="../img/index/t (8).png" alt="">
                            <div class="text">
                                <div class="title">英式经典三方女士风衣</div>
                                <div class="price">￥<span>599</span></div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="#">
                            <img src="../img/index/t (8).png" alt="">
                            <div class="text">
                                <div class="title">英式经典三方女士风衣</div>
                                <div class="price">￥<span>599</span></div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="#">
                            <img src="../img/index/t (8).png" alt="">
                            <div class="text">
                                <div class="title">英式经典三方女士风衣</div>
                                <div class="price">￥<span>599</span></div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="#">
                            <img src="../img/index/t (8).png" alt="">
                            <div class="text">
                                <div class="title">英式经典三方女士风衣</div>
                                <div class="price">￥<span>599</span></div>
                            </div>
                        </a>
                    </li>

                </ul>
            </div>

            <!-- 精选 -->
            <div class="selection content-item">
                <div class="headline">
                    <p>精选优品</p>
                    <p>SELECTION</p>
                </div>
                <ul>
                    <li>
                        <a href="#">
                            <div class="img-box">
                                <img src="../img/index/selection1.png" alt="">
                            </div>
                            <div class="title">
                                <span>本家HOME</span>
                                <span class="price">29.9元起</span>
                            </div>
                            <div class="subtitle">没满100立减20元</div>
                        </a>
                    </li>
                    <li>
                        <a href="#">
                            <div class="img-box">
                                <img src="../img/index/selection1.png" alt="">
                            </div>
                            <div class="title">
                                <span>本家HOME</span>
                                <span class="price">29.9元起</span>
                            </div>
                            <div class="subtitle">没满100立减20元</div>
                        </a>
                    </li>
                    <li>
                        <a href="#">
                            <div class="img-box">
                                <img src="../img/index/selection1.png" alt="">
                            </div>
                            <div class="title">
                                <span>本家HOME</span>
                                <span class="price">29.9元起</span>
                            </div>
                            <div class="subtitle">没满100立减20元</div>
                        </a>
                    </li>
                </ul>
            </div>

            <!-- 好物推荐 -->
            <div class="recommend content-item">
                <div class="headline">
                    <p>好物推荐</p>
                    <p>RECOMMEND</p>
                </div>
                <ul>

                    <li>
                        <a href="#">
                            <div class="img-box">
                                <img src="../img/index/yifu.png" alt="">
                            </div>
                            <div class="text">
                                <p class="title text-overflow">珊瑚绒加厚保暖连体衣珊瑚绒加厚保暖连体衣珊瑚绒加厚保暖连体衣</p>
                                <p class="subtitle text-overflow">珊瑚绒御寒 加厚保暖 纯棉内里</p>
                                <p class="price">￥<span>259</span></p>
                            </div>
                        </a>
                    </li>

                    <li>
                        <a href="#">
                            <div class="img-box">
                                <img src="../img/index/yifu.png" alt="">
                            </div>
                            <div class="text">
                                <p class="title text-overflow">珊瑚绒加厚保暖连体衣珊瑚绒加厚保暖连体衣珊瑚绒加厚保暖连体衣</p>
                                <p class="subtitle text-overflow">珊瑚绒御寒 加厚保暖 纯棉内里</p>
                                <p class="price">￥<span>259</span></p>
                            </div>
                        </a>
                    </li>

                    <li>
                        <a href="#">
                            <div class="img-box">
                                <img src="../img/index/yifu.png" alt="">
                            </div>
                            <div class="text">
                                <p class="title text-overflow">珊瑚绒加厚保暖连体衣珊瑚绒加厚保暖连体衣珊瑚绒加厚保暖连体衣</p>
                                <p class="subtitle text-overflow">珊瑚绒御寒 加厚保暖 纯棉内里</p>
                                <p class="price">￥<span>259</span></p>
                            </div>
                        </a>
                    </li>

                </ul>
            </div>
        </div>




    </div>


    <!-- 底部导航 -->
    <nav class="bottom-nav">
        <a class="active" href="#">
            <img src="../img/footer/首页2.png" alt="">
            <span>首页</span>
        </a>
        <a href="selection.html">
            <img src="../img/footer/钻石 (1).png" alt="">
            <span>优选</span>
        </a>
        <a href="#">
            <img src="../img/footer/分类2.png" alt="">
            <span>分类</span>
        </a>
        <a href="cart.html">
            <img src="../img/footer/购物车2.png" alt="">
            <span>购物车</span>
        </a>
        <a href="personal_center.html">
            <img src="../img/footer/我的2.png" alt="">
            <span>我的</span>
        </a>
    </nav>


    <!-- 侧边栏 -->
    <div id="sidebar" class="sidebar sidebar-login">
        <div class="avator">
            <a href="./personal_center.html">
                <img src="../img/user/avator.png" alt="">
            </a>
            <p>我的名字</p>
        </div>
        <ul>
            <li>
                <a href="#">
                    <span class="icon-box"><i class="fa fa-eye" aria-hidden="true"></i></span>
                    <span>我的关注</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="icon-box"><i class="fa fa-star-o" aria-hidden="true"></i></span>
                    <span>我的收藏</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="icon-box"><i class="fa fa-commenting-o" aria-hidden="true"></i></span>
                    <span>消息</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="icon-box"><i class="fa fa-heart-o" aria-hidden="true"></i></span>
                    <span>心愿单</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="icon-box"><i class="fa fa-credit-card" aria-hidden="true"></i></span>
                    <span>我的钱包</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="icon-box"><i class="fa fa-paper-plane-o" aria-hidden="true"></i></span>
                    <span>发布动态</span>
                </a>
            </li>
            <li>
                <a href="./setting.html">
                    <span class="icon-box"><i class="fa fa-cog" aria-hidden="true"></i></span>
                    <span>设置</span>
                </a>
            </li>
        </ul>
        <div class="microphone">
            <i class="fa fa-microphone" aria-hidden="true"></i>
            <span>试一下</span>
            <span>看你能发现什么？</span>
        </div>
    </div>


    <div id="sidebar" class="sidebar sidebar-no-login">

        <ul>
            <li>
                <a href="#">
                    <span class="icon-box">女士</span>
                    <span>WOMEN</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="icon-box">男士</span>
                    <span>MEN</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="icon-box">婴儿</span>
                    <span>KIDS</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="icon-box">居家</span>
                    <span>LIVING</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="icon-box">配饰</span>
                    <span>ACCESSORT</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="icon-box">餐饮</span>
                    <span>KIT</span>
                </a>
            </li>
            <li>
                <a href="./setting.html">
                    <span class="icon-box">饮食</span>
                    <span>DIET</span>
                </a>
            </li>
            <li>
                <a href="./setting.html">
                    <span class="icon-box">杂货</span>
                    <span>GROCERY</span>
                </a>
            </li>
        </ul>
        <div class="microphone">
            <i class="fa fa-microphone" aria-hidden="true"></i>
            <span>试一下</span>
            <span>看你能发现什么？</span>
        </div>
    </div>
</body>

<script>
    let oSidebarBtn = document.querySelector('#sidebar-btn')
    let oSideber = document.querySelector('#sidebar')
    let oIndexBox = document.querySelector('.index-box')
    let oHeader = document.querySelector('header')
    let oFooter = document.querySelector('.bottom-nav')
    let body = document.body

    oSidebarBtn.addEventListener('click', () => {

        body.classList.toggle('to-right')

        if (body.classList.contains('to-right')) {
            body.addEventListener('touchend', touchEnd, false)
        }
    })

    function touchEnd(event) {
        console.log(event.target.matches('body'));
        if (event.target.matches('body')) {
            body.classList.remove('to-right')
            body.removeEventListener('touchend', touchEnd)
        }
    }

    function touchStart(event) {
        console.log(event);
        let touch = event.targetTouches[0]
        x = touch.pageX
        console.log('x:' + x);
    }

    function touchMove(event) {
        let newX = event.targetTouches[0].pageX
        console.log(newX);
        if (newX < (x - 50)) {
            body.classList.remove('to-right')
                // body.removeEventListener('touchstart')
        }
    }

    function returnIndex() {
        let x = 0
        console.log(event.targetTouches[0]);
        body.addEventListener('touchstart', touchStart, false)
        body.addEventListener('touchmove', touchMove, false)


        body.addEventListener('touchend', () => {
            body.removeEventListener('touchstart', touchStart)
            body.removeEventListener('touchmove', touchMove)
            console.log('touchend');
        })
    }

    function touchMove(event) {
        let newX = event.targetTouches[0].pageX
        console.log(newX);
        if (newX < (x - 50)) {
            body.classList.remove('to-right')
                // body.removeEventListener('touchstart')
        }
    }
</script>

</html>